alter procedure [dbo].[loginState_new] @parentDeptId as varchar(50) as
    declare @resultTab table (
        tRow int identity(1,1),
        deptName varchar(50),
        onlineCount int,
        allCount int,
        orderCount int,
        recentTime datetime
                             )
    declare @tmpInt int;
    declare @deptName varchar(50);
    declare @onlineCount int;
    declare @allCount int;
    declare @orderCount int;
    declare @recentTime datetime;
    declare @subDeptName varchar(50);
    declare @subDeptId varchar(50);
    begin
        declare subDeptList cursor for with deptTree as ( select NoUnit,NoSelf,DeptShort from bUserDept where pno = @parentDeptId and IsDel = 0 and UseState = 1 union all select b.NoUnit,b.NoSelf,b.DeptShort from deptTree t,bUserDept b where t.NoSelf = b.pno and b.UseState = 1 and b.IsDel = 0)
        select NoSelf subDeptId,DeptShort subDeptName from deptTree;
        open subDeptList;
        fetch subDeptList into @subDeptId,@subDeptName
        while (@@FETCH_STATUS = 0)
            begin
                -- 部门名称
                select @deptName = @subDeptName
                -- 部门人数

            end
    end